<%--
  author: winkyle
  date: 2018/11/27
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- jsp文件头和头部 -->
    <%@ include file="../../base/top.jsp"%>
    <style>

    </style>
</head>
<body class="no-skin">
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <table id="data-tablep" width="100%" class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>
                                    <input type="checkbox" id="check-all"/>
                                </th>
                                <th>序号</th>
                                <th>项目名称</th>
                                <th>项目进度</th>
                                <th>组长</th>
                                <th>组员</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <a class="btn btn-xs btn-primary"
                           id="load-all"
                           title="批量下载" style="float: left"><i
                                class="ace-icon fa fa-download bigger-140"></i></a>

                        <a class="btn btn-xs btn-success"
                           title="批量下载"><i class="ace-icon fa fa-leaf bigger-140" onclick="addGrop()">添加分组</i></a>
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div>

    <%--<a href="material/Android_v9.pdf" class="downloadable">2</a>--%>
    <!-- /.main-content -->
    <!-- 返回顶部 -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div>


<form id="uploadForm">
    <input type="file" id="file" name="file"
           style="filter:alpha(opacity=0);opacity:0;width: 0;height: 0;"/>
</form>
<!-- /.main-container -->
<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../../base/foot.jsp"%>
<script type="text/javascript" src="static/js/common/steps.js"></script>
<script type="text/javascript">
    $(top.hangge());

    $("#load-all").click(function () {
        var checked = getAllCheckedRowValue();
        for (var index = 0; index < checked.length; index++) {
            download(checked[index].courseMaterialName+checked[index].fileType, checked[index].courseMaterialAddress);
        }
    });


    var table = null;
    var url='project/search_group_details';
    var param = {teachCourseId:"${teachCourseId}"};
    var columnsData =  [
        {
            bSortable : false,
            className : "text-left",
            width : "50px",
            render : function(data, type, row, meta) {
                return "<input type=\"checkbox\"/>";
            }
        },
        {
            bSortable : false,
            data: null,
            width : "40px",
            className: 'text-center whiteSpace',
            render:function(data,type,row,meta) {
                return meta.row + 1 +
                    meta.settings._iDisplayStart;
            }
        },
        {'data': 'projectName'},
        {
            'data': 'stageCompleteDetails',
            bSortable : false,
            render:function(data,type,row,meta) {
                var html="";
                html+=getStepsBar(data,"stageName",new Array("stageGrade","stageStartTime"),"stageComplete");
                return html;
            }
        },
        {
            'data': 'groupMembers',
            bSortable : false,
            render:function(data,type,row,meta) {
                var str;
                for(var i=0;i<data.length;i++){
                    if(data[i].groupIdentity==0) {
                        str = data[i].stuName;
                    }
                }
                return "<p>"+str+"</p>";
            }
        },
        {
            'data': 'groupMembers',
            bSortable : false,
            render:function(data,type,row,meta) {
                var str = '';
                for(var i=0;i<data.length;i++){
                    if(data[i].groupIdentity!=0) {
                        if(str!=''){
                            str += ',';
                        }
                        str += data[i].stuName;
                    }
                }
                return "<p>"+str+"</p>";
            }
        },
        {
            bSortable : false,
            data: null,
            width : "40px",
            className: 'text-center whiteSpace',
            render:function(data,type,row,meta) {
                var id = '"' + row.id + '"';
                var html = "";
                html += "<a href='javascript:void(0);' onclick='editLabelLib(this)' class='btn btn-primary btn-xs'>修改分组</a>";
                html += "<a href='javascript:void(0);' onclick='editStage(this)' class='btn btn-primary btn-xs'>阶段判定</a>";
                return html;
            }
        }
    ];
    var dataBaseFiled =  [
        {'data': 'project_name'},
        {'data': 'project_update_time'}
    ];
    $(document).ready(function() {
        table = $('#data-tablep').DataTable($.extend(true,{},CONSTANT.DATA_TABLES.DEFAULT_OPTION,{
            columns:columnsData,
            ajax: function (data,callback) {
                ajax(data,callback,dataBaseFiled,url,param);
            },
            order:[[ 3, "asc" ]]
        }));
    });
    function addGrop() {
        var diag = new top.Dialog();
        diag.Drag=true;
        diag.Title ="添加";
        diag.URL = "<%=basePath%>group/toAddGroup";
        diag.Width = 550;
        diag.Height = 368;
        diag.CancelEvent = function(){ //关闭事件
            var success = diag.innerFrame.contentWindow.document.getElementById('success').value;
            var msg = diag.innerFrame.contentWindow.document.getElementById('msg').value;
            diag.close();
            if("true" == success){
                operateSuccess(msg);
            }else if("false" == success){
                operateError(msg);
            }
        };
        diag.show();
    }
    function editStage(button) {
        var json =  getClickedRowValue(button);
        top.addTab('113','113','项目阶段详情','<%= basePath%>project_stage/view',{
            'projectId': json['projectId']
        })
    }

</script>

</body>
</html>